package com.ys.web.mobao.service;

import com.ys.utils.base.j2se.StringHandler;
import com.ys.utils.spring.properties.Config;
import com.ys.web.mobao.mapper.MobaoBindCardMapper;
import com.ys.web.mobao.model.po.BindCard;
import com.ys.web.mobao.model.po.SystemBankPO;
import com.ys.web.pay.model.vo.UserBank;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class MobaoBindCardService {
    @Autowired
    private MobaoBindCardMapper mobaoBindCardMapper;

    public int getUserBankByCardNo(String cardNo){
        return mobaoBindCardMapper.getUserBankByCardNo(cardNo);
    }

    public List<UserBank> getUserBankByUserId(long uid){
        if("ys".equals(StringHandler.getString(Config.pp.get("ys.user.pay.channel"),"ys"))){
            return mobaoBindCardMapper.getUserBankByUserId(uid);
        }
        if("mb".equals(StringHandler.getString(Config.pp.get("ys.user.pay.channel"),"ys"))){
            return mobaoBindCardMapper.getUserBankByUserIdMb(uid);
        }
        return mobaoBindCardMapper.getUserBankByUserId(uid);
    }

    public UserBank getUserBankByToken(String token){
        return mobaoBindCardMapper.getUserBankByToken(token);
    }
    public UserBank getUserBank(String uid,String token){
        return mobaoBindCardMapper.getUserBank(uid,token);
    }
    public void saveUserBank(BindCard bindCard){
        mobaoBindCardMapper.saveUserBank(bindCard);
    }
    public void saveUserBankMb(BindCard bindCard){
        mobaoBindCardMapper.saveUserBankMb(bindCard);
    }
    public int delUserBankByOutTradNo(long uid,String outTradNo){
        return mobaoBindCardMapper.delUserBankByOutTradNo(uid,outTradNo);
    }

    public int delUserBankByCardToken(long uid,String cardToken){
        return mobaoBindCardMapper.delUserBankByCardToken(uid,cardToken);
    }

    public List<SystemBankPO> getAll() {
        return mobaoBindCardMapper.getAll();
    }

    public int updateLinkId(String requestNo, String linkId) {
        return mobaoBindCardMapper.updateLinkId(requestNo,linkId);
    }

    public int delBindCard(String requestNo) {
        return mobaoBindCardMapper.delBindCard(requestNo);
    }

    public int updateBindCard(String requestNo,String cardType,String linkId,String bank_name) {
        return mobaoBindCardMapper.updateBindCard(requestNo,cardType,linkId,bank_name);
    }

    public int saveSysBank(Map<String,Object> bank){
        return mobaoBindCardMapper.saveSysBank(bank);
    }

    public int delUserBankByCardTokenMb(long uid, String cardToken) {
        return mobaoBindCardMapper.delUserBankByCardTokenMb(uid,cardToken);
    }

    public List<SystemBankPO> getAllMb() {
        return mobaoBindCardMapper.getAllMb();
    }

    public int getUserBankCheckCardNo(String cardNo) {
        return mobaoBindCardMapper.getUserBankCheckCardNo(cardNo);
    }
}
